package com.ruoyi.system.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.core.domain.entity.SysOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Mapper
public interface SysOrderMapper extends BaseMapper<SysOrder> {


 @Select("SELECT COUNT(id) from  sys_order")
    Long queryTotal();

   @Select("SELECT COUNT(*) FROM sys_order WHERE result = mark_type")
    Long resultEqualMarkType();


    // 自定义聚合查询
    @Select("SELECT record_no, MAX(create_time) AS create_time, mark_type, result, power_list " +
            "FROM sys_order " +
            "WHERE create_time >= #{startTime} AND create_time < #{endTime} " +
            "GROUP BY record_no, mark_type, result, power_list")
    List<SysOrder> selectOrdersWithAggregations(@Param("startTime") java.sql.Timestamp startTime,
                                                @Param("endTime") java.sql.Timestamp endTime);
}
